
const sequelize = require('../shared/sequelize')
// const Discuss = sequelize.import('./model/discuss')
const Discuss = require('../model/discuss')(sequelize,sequelize.DataTypes)
//发送评论
exports.sendDiscuss = function(userName,content){
    let time = Date.now()
    console.log('create',userName,content,time)
    return Discuss.create({name:userName,content:content,time:time})
}

//查询评论
exports.showDiscuss = async function(){
    // const options = {}
    const {rows,count} = await Discuss.findAndCountAll()
    const disList = rows.map(row=>row.toJSON())
    return {list:disList,count:count}
}